class Solution:
    def productExceptSelf(self, nums: list[int]) -> list[int]:
        size = len(nums)
        newlist = [1 for _ in range(size)]
        left = 1
        right = 1
        for i in range(size):
            newlist[i] *= left
            left *= nums[i]

        for i in range(size-1, -1, -1):
            newlist[i] *= right
            right *= nums[i]
        return newlist

sol = Solution()

nums =[1,2,3,4]
sol.productExceptSelf(nums)